<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.trkj.com/tr1702/tags" prefix="my" %>
<html>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery-easyui-1.5.5.6/locale/easyui-lang-zh_CN.js"/>"></script>
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/default/easyui.css"/>" />
<link rel="stylesheet" type="text/css"
	href="<c:url value="/js/jquery-easyui-1.5.5.6/themes/icon.css"/>" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>培训活动</title>
	<style type="text/css">
		 
	</style>
</head>
<body>	
	<script type="text/javascript">
		var formatters = function(value,row,index){
			<my:g id="90"> 
			var edit = "<a butn='tb_btn_edit' onclick='editrow("+row.trainingId+")'></a>";
			</my:g> 
			<my:g id="89"> 
			var del = "<a butn='tb_btn_del' onclick='delrow("+row.trainingId+")'></a>";
			</my:g> 
			return edit+del;
		}
		//编辑
		var editrow =function(trainingId){
			/* 		var date = new Date(trainingStarttime);
					var date1 = new Date(trainingEndtime);   
					console.log(trainingStarttime+"  "+date.toLocaleString());
					console.log(trainingEndtime+" "+date1.toLocaleString()); */
				$("#cf-trainactivity-win").dialog("open"); 
			/* 	parent.$('.dialog-button a:eq(0)').hide();
				parent.$('.dialog-button a:eq(1)').show();
				parent.$('.dialog-button a:eq(2)').show(); */
				$('#cf-pxhd-1').hide();
				$('#cf-pxhd-2').show();
				$('#cf-pxhd-3').show();
				var vv=$('#cf-trainactivity-tb').datagrid('getSelected');
				$("#cf-trainactivity-ids").textbox('setValue',vv.trainingName);
				//$("#cf-trainactivity-kssj").textbox('setValue',trainingStarttime);
				//$("#cf-trainactivity-jssj").textbox('setValue',trainingEndtime);
				$("#cf-trainactivity-pxdd").textbox('setValue',vv.trainingLocation);
				$("#cf-trainactivity-bz").textbox('setValue',vv.certificateRemarks);
				
		}
		var editdialog = function(){
			$("<form method='get'>").appendTo(document.body).form({
				url:'Traininggactivity_update',
				onSubmit:function(param){
					var vv=$('#cf-trainactivity-tb').datagrid('getSelected');
					//alert(vv.trainingId);
					param['trainingId'] =vv.trainingId;
					param['trainingName'] = $("#cf-trainactivity-ids").textbox('getValue');
					//param['trainingStarttime'] =$("#cf-trainactivity-kssj").textbox('getValue');//vv.trainingStarttime;
					//param['trainingEndtime'] =$("#cf-trainactivity-jssj").textbox('getValue');//vv.trainingEndtime;
					param['trainingLocation'] =$("#cf-trainactivity-pxdd").textbox('getValue');
					param['certificateRemarks'] =$("#cf-trainactivity-bz").textbox('getValue');
				},
				success:function(){
					$('#cf-trainactivity-tb').datagrid('reload');
					$('#cf-trainactivity-win').dialog('close');
				}
			}).submit().appendTo(".abc");	
		}
		 //删除
		var delrow= function(trainingId){
			$.messager.confirm('提示','确定删除该项',function(v){
				if(v){
					$.post('Traininggactivity_remove',{trainingId:trainingId},function(){
						$('#cf-trainactivity-tb').datagrid('reload');
					});
				}
			});
		} 
			$(function(){
				$("#cf-trainactivity-tb").datagrid({onLoadSuccess: function(){
					$("a[butn=tb_btn_edit]").linkbutton({iconCls:'icon-edit', plain:true});
					$("a[butn=tb_btn_del]").linkbutton({iconCls:'icon-cancel', plain:true});
				}});
				//打开新增界面
				$("#cf-trainactivity-add").linkbutton({
					onClick : function() {
						$("#cf-trainactivity-win").dialog("open");
						$("#cf-trainactivity-f").form('clear');
						/* parent.$('.dialog-button a:eq(0)').show();
						parent.$('.dialog-button a:eq(1)').hide();
						parent.$('.dialog-button a:eq(2)').hide(); */
						$('#cf-pxhd-1').show();
						$('#cf-pxhd-2').hide();
						$('#cf-pxhd-3').hide();
					}
				});
				$("#cf-trainactivity-refresh").linkbutton({
					onClick : function() {
						$('#cf-trainactivity-tb').datagrid('reload');
					}
				});
			});
	</script>
	<div class="abc"></div>
	<div id="cf-trainactivity-tbs">
		<my:g id="88"> 
   		 <a id="cf-trainactivity-add" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true,text:'添加'"></a>
    	</my:g> 
 		<a id="cf-trainactivity-refresh" class="easyui-linkbutton" data-options="iconCls:'icon-reload',text:'刷新',plain:true,iconAlign:'right'"></a>
    	 <input class="easyui-searchbox" data-options="label:'搜索',width:300,labelWidth:50,prompt:'活动名称',
     	searcher:function(value,name){
	         $('#cf-trainactivity-tb').datagrid('load','Traininggactivity_searchbox?trainingName='+value);
     	 }">
  </div>
		<table id="cf-trainactivity-tb" class="easyui-datagrid" data-options="
			url:'Traininggactivity_pages',
			fitColumns:true,
			fit:true,
			nowrap:false,
			loading:true,
			pagination:true,
			rownumbers:true,
			singleSelect:true,
			pageSize:10,
    		pageList:[10,20,30,40,50],
			toolbar:'#cf-trainactivity-tbs',
			striped:true,
			method:'get'	
	">
		<thead>
		  <tr>
			<th data-options="field:'trainingId',width:200,align:'center'">活动编号</th>
			<th data-options="field:'trainingName',width:500,align:'center'">活动名称</th>
		<!-- 	<th data-options="field:'sex',width:200,align:'center',
				styler:function(value,row,index){
					if(value==1){
						return 'color:white;background:red;';
					}
				},align:'center'
			">负责人</th> -->
			<th data-options="field:'trainingStarttime',width:300,align:'center',
				formatter:function(value){
					var date = new Date(value);
                        
                        return date.toLocaleString();
				}">创建时间</th>
			<th data-options="field:'trainingEndtime',width:300,align:'center',
				formatter:function(value){
					var date = new Date(value);
                        return date.toLocaleString();
				}">更新时间</th>
			<th data-options="field:'trainingLocation',width:400,align:'center'">培训地点</th>
			<!-- <th data-options="field:'trainingBudget',width:250,align:'center'">预算</th> -->
			<th data-options="field:'certificateRemarks',width:400">备注</th>
			<th data-options="field:'trainingNumberofcourses',width:200,align:'center'">课程数</th>
			<th data-options="field:'trainingAgendanumber',width:200,align:'center'">议程数</th>
			<th data-options="field:'trainingNumberofparticipants',width:200,align:'center'">参与人数</th>
			<th data-options="field:'trainingState',width:200,align:'center'">状态</th>
			<th data-options="field:'9',width:250,align:'center',formatter:formatters">操作</th>
		  </tr>	
		</thead>
		<tbody>
			 
		</tbody>
	</table>
	<div id="cf-trainactivity-win" class="easyui-dialog"data-options="width:400, height:200,
			title:'培训活动',
     		bodyCls:'Traininggactivity_add',
      		modal:true,
      		closed:true,
      		buttons:[{
	        	text:'提交',
				id:'cf-pxhd-1',
	        	iconCls:'icon-ok',
        		handler:function(){
          		 $('#cf-trainactivity-f').form({
            		onSubmit:function(param){
						
            		 //验证表单
						//var cc=$('#cf-trainactivity-ids').textbox('getValue');
             			 return $(this).form('validate');
            		},
	           		 success:function(v){
	              		//$.messager.alert('提示','注册成功');
						$('#cf-trainactivity-tb').datagrid('reload');
						$('#cf-trainactivity-win').dialog('close');
	            	}
          	    }).submit();
       		  }
      		},{
        	text:'保存',
			id:'cf-pxhd-2',
        	iconCls:'icon-save',
	        	handler:editdialog
			},{
        	text:'清除',
			id:'cf-pxhd-3',
        	iconCls:'icon-cancel',
	        	handler:function(){
	          		 $('#cf-trainactivity-f').form('clear');
	        	}
			},{
        	text:'取消',
        	iconCls:'icon-cancel',
	        	handler:function(){
	          		$('#cf-trainactivity-win').dialog('close');
	        	}
			}
			]">
		<form id="cf-trainactivity-f" action="Traininggactivity_add" method="get">
			<div class="line">
				        <input id="cf-trainactivity-ids" class="easyui-textbox" name="trainingName"
					data-options="label:'活动名称',width:250">
			</div>
			
			<!-- <div class="line">
				        开始时间&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<input id="cf-trainactivity-kssj" class="easyui-datebox" name="trainingStarttime"
					data-options="width:125">
			</div>
			
			<div class="line">
				        结束时间&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="cf-trainactivity-jssj" 
				class="easyui-datebox" name="trainingEndtime" data-options="width:125">
			</div> -->
			
			<div class="line">
				        <input id="cf-trainactivity-pxdd" class="easyui-textbox" name="trainingLocation"
					data-options="label:'培训地点',width:250">
			</div>
			 
			<div class="line">
				        <input id="cf-trainactivity-bz" class="easyui-textbox" name="certificateRemarks"
					data-options="label:'备注',width:350,multiline:true,height:50">
			</div>
		</form>
	</div>

</body>
</html>